/**
 * @description  : 人员选择
 * @descriptionDetail : 人员选择
 * @copyright    : 浙江烟草
 * @author       : mc
 * @create       : 2022-10-03 16:51:52
 */
<template>
  <view style="width: 100%;">
    <u-input
      :border="false"
      type="select"
      :placeholder="$attrs.placeholder || '请选择'"
      v-model="value"
      v-bind="$attrs"
      @click="userSelectShow = !readOnly"
      :select-open="userSelectShow"
    ></u-input>
    <u-popup mode="bottom" height="60%" v-model="userSelectShow">
      <user-select :isSingle="isSingle" :treeType="treeType" @choose="selectUser"></user-select>
    </u-popup>
  </view>
</template>
<script>
import UserSelect from "./user-select.vue"
export default {
  components: {UserSelect},
  props: {
    value: {
      type: String | Number,
      default: ''
    },
    // 单选或多选, 默认单选
    isSingle: {
      type: Boolean,
      default: true,
    },
    treeType: {
      type: String,
      default:"zm-user",
    },
    readOnly: { // 只读
     type: Boolean,
      default: false
    }
  },
  data() {
    return {
      border: false,
      userSelectShow: false,
    }
  },
  watch: {
    
  },
  created () {
  },
  methods: {
    selectUser(users) {
      this.$emit("confirm", {
        name: users.map(a => a.name).join(","),
        value: users.map(a => a.id).join(",")
      });
      this.userSelectShow = false;
    }
  },
}
</script>